<div class="container">
  <section>
    <h2>工程项目
      <div class="pull-right" ng-if="currentUser.role != '普通员工' || currentUser.department.name == '综合部'">
        <a ui-sref="app.projects-add">
          <small class="text-primary">
            <i class="fa fa-plus"></i>
            添加项目
          </small>
        </a>
      </div>
    </h2>

    <div class="table-responsive">
      <table class="table table-striped">
        <thead><tr>
          <th>编号</th>
          <th>项目名 <a href="" ng-click="orderByField='name'; reverseSort = !reverseSort"><i class="fa fa-sort"></i></a></th>
          <th>负责人 <a href="" ng-click="orderByField='user.name'; reverseSort = !reverseSort"><i class="fa fa-sort"></i></a></th>
          <th>开工日期 <a href="" ng-click="orderByField='start_date'; reverseSort = !reverseSort"><i class="fa fa-sort"></i></a></th>
          <th>工程类型 <a href="" ng-click="orderByField='type'; reverseSort = !reverseSort"><i class="fa fa-sort"></i></a></th>
          <th>工程进度 <a href="" ng-click="orderByField='progress'; reverseSort = !reverseSort"><i class="fa fa-sort"></i></a></th>
          <th>资料数 <a href="" ng-click="orderByField='files.length'; reverseSort = !reverseSort"><i class="fa fa-sort"></i></a></th>
          <th>创建日期  <a href="" ng-click="orderByField='created_at'; reverseSort = !reverseSort"><i class="fa fa-sort"></i></a></th>
          <th>是否竣工 <a href="" ng-click="orderByField='completed'; reverseSort = !reverseSort"><i class="fa fa-sort"></i></a></th>
          <th>操作</th>
        </tr>
        </thead>
        <tbody>
          <tr ng-repeat="project in projects | orderBy:orderByField:reverseSort">
            <td>{{$index+1}}</td>
            <td>{{project.name}}</td>
            <td>{{project.leader.name}}</td>
            <td>{{project.start_date | date: 'yyyy/MM/dd'}}</td>
            <td>{{project.type}}</td>
            <td>{{project.progress}}</td>
            <td><span class="badge"> {{project.files.length}}</span></td>
            <td>{{project.created_at | date: 'yyyy/MM/dd'}}</td>
            <td><i ng-class="{'fa fa-check-square-o text-success': project.is_completed, 'fa fa-remove text-danger': !project.is_completed}"></i></td>
            <td><a ui-sref="app.projects-detail({projectId: project._id})">查看</a> </td>
          </tr>
        </tbody>
      </table>
      <p class="lead text-center" style="margin: 80px auto" ng-if="!projects.length"><i class="fa fa-exclamation-triangle"></i> 没有找到任何工程项目！</p>
    </div>
  </section>
</div>
